﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Subject_PointColumn
    {
            public long ID{get;set;}
            public long SubjectID { get; set; }
            public long PointColumnID { get; set; }
            public bool IsDeleted { get; set; }
        [Description("Môn học")]
            public string SubjectNameExt { get; set; }
        [Description("Tên cột điểm")]
            public string PointColumnNameExt { get; set; }
        [Description("Hệ số")]
            public string FactorExt { get; set; }
        public Subject_PointColumn()
        {
            IsDeleted = false;
        }
        
       static Subject_PointColumn DynamicCast<T>(object row_data, object row_header) where T : Subject_PointColumn
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Subject_PointColumn ret = new Subject_PointColumn();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "SubjectID":
                       ret.SubjectID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "PointColumnID":
                       ret.PointColumnID = ConvertObject.ToLong(dt[column]);
                       break;
                      case "SubjectName":
                       ret.SubjectNameExt = ConvertObject.ToString(dt[column]);
                       break;
                      case "PointColumnName":
                       ret.PointColumnNameExt = ConvertObject.ToString(dt[column]);
                       break;
                      case "Factor":
                       ret.FactorExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "IsDeleted":
                       ret.IsDeleted = ConvertObject.ToBool(dt[column]);
                       break;
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
